package cn.itsource.feign.fallback;

import cn.itsource.feign.client.TenantFeign;
import cn.itsource.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author Jason
 * @date 2022-09-14 17:08
 */
@Component
public class TenantFeignFallbcakFactory implements FallbackFactory<TenantFeign> {

    @Override
    public TenantFeign create(Throwable throwable) {
        return new TenantFeign(){

            @Override
            public JSONResult getTenantInfoByUserId(Long userId) {
                throwable.printStackTrace();
                return JSONResult.error("调用系统服务出现异常");
            }
        };
    }
}
